home *** CD-ROM | disk | FTP | other *** search
/ Winzipper / Winzipper_ISO.iso / internet / net commander 1.0 / ISP / SCRPTLST / MSPRING.CMD < prev    next >
Encoding:
Text File  |  1996-02-15  |  5.0 KB  |  226 lines

  1. # -------------------------------------------------------------------------
  2. #    Trumpet Winsock Login.cmd for MindSpring Enterprises, Inc.
  3. #
  4. # This script requires Trumpet Winsock version 1.0b, alpha 19 or later
  5. #
  6. #
  7. # Some things you may wish to modify:
  8. #    $phone       - the telephone number to dial
  9. #    $phone2      - alternate telephone number
  10. #    $name        - your user ID
  11. #    $init        - the initialisation string for your modem
  12. #    %numretries  - how often to retry dialling (0 = forever!)
  13. #    %numlogin    - how often to retry login    (0 = forever!)
  14. #    $badlogin    - string returned by host for failed login attempt
  15. #
  16. # For the first three of the above, making the value a single space (" ")
  17. # will cause the script to prompt you for a value.
  18. #
  19. # Version 2.00, Karl Auer
  20. # Version 2.10, Jerry Britton
  21. #
  22. # modified for MindSpring by Robert Sanders -- Nov 24, 1994
  23. # -------------------------------------------------------------------------
  24.  
  25. # Turn off both echoing of modem "chatter" and display of commands.
  26. #
  27. echo on
  28. #trace on
  29.  
  30. # User-definable stuff
  31.  
  32. $defaultnum  = "6541300"
  33. $defaultprefix = ""
  34. $defaultinit = "AT Z V1 X4"
  35.  
  36. if ![load $number]
  37.   $number = $defaultnum
  38.   if [query $number "Enter your dial up phone number #1"]
  39.     save $number
  40.   end
  41. end
  42. if ![load $number2]
  43.   $number2 = $number
  44.   if [query $number2 "Enter your dial up phone number #2"]
  45.     save $number2
  46.   end
  47. end
  48. if ![load $prefix]
  49.   $prefix = $defaultprefix
  50.   if [query $prefix "Enter your dial prefix (e.g. *70 or 1404)"]
  51.     save $prefix
  52.   end
  53. end
  54.  
  55. if ![load $musername]
  56.   if [query $musername "Enter your login username"]
  57.     save $musername
  58.   end
  59. end
  60. if ![load $mword]
  61.   if [query $mword "Enter your login password"]
  62.     save $mword
  63.   end
  64. end
  65.  
  66. if ![load $init]
  67.   $init = $defaultinit
  68.   save $init
  69. end
  70.  
  71. # some constants
  72.  
  73. $userprompt = "ogin:"
  74. $passprompt = "assword:"
  75. %numretries = 20
  76. %numlogin   = 3
  77.  
  78. $phone  = $number
  79. $phone2 = $number2
  80.  
  81. # -------------------------------------------------------------------------
  82. #
  83. # Do not alter anything below this line unless you know what you are doing!
  84. #
  85. # -------------------------------------------------------------------------
  86.  
  87. # Now try to connect.
  88.  
  89. %attempts = 0
  90. $result = " "
  91. repeat
  92.    # count our attempts
  93.    %attempts = %attempts + 1
  94.  
  95.    # hang up the modem
  96.    set dtr off
  97.    sleep 1
  98.    set dtr on
  99.  
  100. ###   # reset the modem
  101. ###   display "Resetting modem..."\n
  102. ###   outputecho ATZ\r
  103. ###   if ![input 10 OK\n]
  104. ###      display "Can't reset modem. Aborting script."\n
  105. ###      display \7
  106. ###      abort
  107. ###   end
  108.  
  109.    # reinitialise the modem
  110.    display "Initialising modem...("$init")"\n
  111.    output $init\13
  112.    if ![input 10 OK\n]
  113.       display "Can't initialise modem. Aborting script."\n
  114.       display \7
  115.       abort
  116.    end
  117.  
  118.    # dial out
  119.    if %attempts = 1
  120.       display "Dialling "$prefix$phone"..."
  121.    else
  122.       display "Redialling "$prefix$phone" (attempt #"%attempts")..."
  123.    end
  124.    output "ATDT"$prefix$phone\13
  125.  
  126.    # swap phone numbers
  127.    if $phone2 <> " "
  128.      $temp   = $phone
  129.      $phone  = $phone2
  130.      $phone2 = $temp
  131.    end
  132.  
  133.    # wait for a connection
  134.    %connected = 0
  135.  
  136.    repeat 
  137.      %responded = [read 45 $result]
  138.    until ! %responded | $result <> ""
  139.  
  140.    if %responded
  141.       if $result = "NO DIALTONE"
  142.          display "No dialtone detected."\n 
  143.       else 
  144.          if $result = "BUSY"
  145.             display "Number is busy."\n
  146.          else
  147.             if $result = "NO CARRIER"
  148.               display "No answer."\n
  149.             else
  150.                %connected = 1
  151.                if %connected
  152.                  display "Connect string was: "$result\n
  153.                else
  154.                  display "No data carrier detect signal..."$result\n
  155.                end  
  156.             end
  157.          end
  158.       end
  159.    else
  160.      display "No answer."\n  
  161.    end
  162. until %connected | %attempts = %numretries
  163.  
  164. # If we didn't get a connection, quit the script
  165.  
  166. if ! %connected
  167.    display "Unable to connect."\n
  168.    display \7
  169.    abort
  170. end
  171.  
  172. # We are now connected.
  173.  
  174. display "Connected. Negotiating logon:"\n
  175.  
  176. # Prod the terminal server to wake it up.
  177. # output \r
  178.  
  179. # Attempt login, prompting for password with each attempt.
  180.  
  181. %login = 0
  182. %attempts = 0
  183. repeat
  184.   # count our attempts
  185.   %attempts = %attempts + 1
  186.  
  187. #  display "   - supplying user ID..."\n
  188.   input 30 $userprompt
  189.   output $musername\13
  190.  
  191.   # Wait for the password prompt, then pass the password on to the terminal
  192.   # server.
  193.  
  194. #  display "   - supplying password..."\n
  195.   input 30 $passprompt
  196.   output $mword\13
  197.  
  198.   %login = 1
  199.   if ![input 60 acket mode]
  200.      display "Connected but session not initiated."\n
  201.      %login = 0
  202.   end
  203. until %login | %attempts = %numlogin
  204.  
  205.  
  206. if ! %login
  207.   display "Login failed.  Hanging up"\n
  208.   display \7
  209.   set dtr off
  210.   sleep 1
  211.   output +++
  212.   if [input 2 OK\n]
  213.     output ATH0\n
  214.     input 10 OK\n
  215.   end
  216.   abort
  217. end
  218.  
  219. # Finish up.
  220.  
  221. display \n
  222. display "Ready."\n
  223.  
  224. # All done.
  225. # END OF SCRIPT
  226.